<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- qtgui.qdoc -->
  <title>Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td >Qt GUI</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.14.2 参考文档</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#using-the-module">Using the Module</a></li>
<li class="level2"><a href="#building-with-cmake">Building with CMake</a></li>
<li class="level2"><a href="#building-with-qmake">Building with qmake</a></li>
<li class="level1"><a href="#application-windows">Application Windows</a></li>
<li class="level1"><a href="#2d-graphics">2D Graphics</a></li>
<li class="level1"><a href="#opengl-and-opengl-es-integration">OpenGL and OpenGL ES Integration</a></li>
<li class="level1"><a href="#vulkan-integration">Vulkan Integration</a></li>
<li class="level1"><a href="#drag-and-drop">Drag and Drop</a></li>
<li class="level1"><a href="#licenses-and-attributions">Licenses and Attributions</a></li>
<li class="level1"><a href="#reference">Reference</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt GUI</h1>
<span class="subtitle"></span>
<!-- $$$qtgui-index.html-description -->
<div class="descr"> <a name="details"></a>
<p>Qt GUI模块提供了用于窗口系统集成、事件处理、OpenGL和OpenGL ES集成、2D图形、基本图像、字体和文本的类。这些类由Qt的用户界面技术在内部使用，也可以直接使用，例如使用低级OpenGL ES图形api编写应用程序。</p>
<p>对于编写用户界面的应用程序开发人员来说，Qt提供了更高级别的API，比如 Qt Quick，它比 Qt GUI 模块中的 enablers 更适合。</p>
<a name="using-the-module"></a>
<h2 id="using-the-module">Using the Module</h2>
<p>Using a Qt module requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including <a href="http://www.cmake.org/cmake/help/documentation.html">CMake</a> and <a href="../qmake/qmake-manual.html">qmake</a>.</p>
<a name="building-with-cmake"></a>
<h3 id="building-with-cmake">Building with CMake</h3>
<p>Use the <code>find_package()</code> command to locate the needed module components in the <code>Qt5</code> package:</p>
<pre class="cpp">

  find_package(Qt5 COMPONENTS Gui REQUIRED)
  target_link_libraries(mytarget Qt5::Gui)

</pre>
<p>See also the Build with CMake overview.</p>
<a name="building-with-qmake"></a>
<h3 id="building-with-qmake">Building with qmake</h3>
<p>If you use <a href="../qmake/qmake-manual.html">qmake</a> to build your projects, Qt GUI is included by default. To disable Qt GUI, add the following line to your <code>.pro</code> file:</p>
<pre class="cpp">

  QT -= gui

</pre>
<a name="application-windows"></a>
<h2 id="application-windows">Application Windows</h2>
<p>The most important classes in the Qt GUI module are <a href="qguiapplication.html">QGuiApplication</a> and <a href="qwindow.html">QWindow</a>. A Qt application that wants to show content on screen, will need to make use of these. <a href="qguiapplication.html">QGuiApplication</a> contains the main event loop, where all events from the window system and other sources are processed and dispatched. It also handles the application's initialization and finalization.</p>
<p>The <a href="qwindow.html">QWindow</a> class represents a window in the underlying windowing system. It provides a number of virtual functions to handle events (<a href="../qtcore/qevent.html">QEvent</a>) from the windowing system, such as touch-input, exposure, focus, key strokes and geometry changes.</p>
<a name="2d-graphics"></a>
<h2 id="2d-graphics">2D Graphics</h2>
<p>The Qt GUI module contains classes for 2D graphics, imaging, fonts and advanced typography.</p>
<p>A <a href="qwindow.html">QWindow</a> created with the surface type <a href="qsurface.html#SurfaceType-enum">QSurface::RasterSurface</a> can be used in combination with <a href="qbackingstore.html">QBackingStore</a> and <a href="qpainter.html">QPainter</a>, Qt's highly optimized 2D vector graphics API. <a href="qpainter.html">QPainter</a> supports drawing lines, polygons, vector paths, images and text. For more information, see <a href="paintsystem.html">Paint System</a> and <a href="qtgui-rasterwindow-example.html">Raster Window Example</a>.</p>
<p>Qt can load and save images using the <a href="qimage.html">QImage</a> and <a href="qpixmap.html">QPixmap</a> classes. By default, Qt supports the most common image formats including JPEG and PNG among others. Users can add support for additional formats via the <a href="qimageioplugin.html">QImageIOPlugin</a> class. For more information, see <a href="paintsystem-images.html">Reading and Writing Image Files</a></p>
<p>Typography in Qt is done with <a href="qtextdocument.html">QTextDocument</a> which uses the <a href="qpainter.html">QPainter</a> API in combination with Qt's font classes, primarily <a href="qfont.html">QFont</a>. Applications that prefer more low-level APIs to text and font handling, classes like <a href="qrawfont.html">QRawFont</a> and <a href="qglyphrun.html">QGlyphRun</a> can be used.</p>
<a name="opengl-and-opengl-es-integration"></a>
<h2 id="opengl-and-opengl-es-integration">OpenGL and OpenGL ES Integration</h2>
<p><a href="qwindow.html">QWindow</a> supports rendering using OpenGL and OpenGL ES, depending on what the platform supports. OpenGL rendering is enabled by setting the <a href="qwindow.html">QWindow</a>'s surface type to <a href="qsurface.html#SurfaceType-enum">QSurface::OpenGLSurface</a>, choosing the format attributes with <a href="qsurfaceformat.html">QSurfaceFormat</a>, and then creating a <a href="qopenglcontext.html">QOpenGLContext</a> to manage the native OpenGL context. In addition, Qt has <a href="qopenglpaintdevice.html">QOpenGLPaintDevice</a>, which enables the use of OpenGL accelerated <a href="qpainter.html">QPainter</a> rendering, as well as convenience classes that simplify the writing of OpenGL code and hides the complexities of extension handling and the differences between OpenGL ES 2 and desktop OpenGL. The convenience classes include <a href="qopenglfunctions.html">QOpenGLFunctions</a> that lets an application use all the OpenGL ES 2 functions on desktop OpenGL without having to manually resolve the OpenGL function pointers, thus allowing cross-platform development of applications targeting mobile or embedded devices, and some classes that wrap native OpenGL functionality in a simpler Qt API:</p>
<ul>
<li><a href="qopenglbuffer.html">QOpenGLBuffer</a></li>
<li><a href="qopenglframebufferobject.html">QOpenGLFramebufferObject</a></li>
<li><a href="qopenglshaderprogram.html">QOpenGLShaderProgram</a></li>
<li><a href="qopengltexture.html">QOpenGLTexture</a></li>
<li><a href="qopengldebuglogger.html">QOpenGLDebugLogger</a></li>
<li><a href="qopengltimerquery.html">QOpenGLTimerQuery</a></li>
<li><a href="qopenglvertexarrayobject.html">QOpenGLVertexArrayObject</a></li>
</ul>
<p>Finally, in order to provide better support for the newer versions (3.0 and higher) of OpenGL, a versioned function wrapper mechanism is also available: The QOpenGLFunction_N_N family of classes expose all the functions in a given OpenGL version and profile, allowing easy development of desktop applications relying on modern, desktop-only OpenGL features.</p>
<p>For more information, see the <a href="qtgui-openglwindow-example.html">OpenGL Window Example</a>.</p>
<p>The Qt GUI module also contains a few math classes to aid with the most common mathmatical operations related to 3D graphics. These classes include <a href="qmatrix4x4.html">QMatrix4x4</a>, <a href="qvector4d.html">QVector4D</a> and <a href="qquaternion.html">QQuaternion</a></p>
<p>A <a href="qwindow.html">QWindow</a> created with the <a href="qsurface.html#SurfaceType-enum">QSurface::OpenGLSurface</a> can be used in combination with <a href="qpainter.html">QPainter</a> and <a href="qopenglpaintdevice.html">QOpenGLPaintDevice</a> to have OpenGL hardware accelerated 2D graphics, by sacrificing some of the visual quality.</p>
<a name="vulkan-integration"></a>
<h2 id="vulkan-integration">Vulkan Integration</h2>
<p>Qt 5.10 added support for <a href="https://www.khronos.org/vulkan/">Vulkan</a>. This requires the presence of the <a href="https://www.lunarg.com/vulkan-sdk/">LunarG Vulkan SDK</a>.</p>
<p>On Windows, the SDK sets the environment variable <code>VULKAN_SDK</code>, which will be detected by the <code>configure</code> script.</p>
<p>On Android, Vulkan headers were added in API level 24 of the NDK.</p>
<p>Relevant classes:</p>
<ul>
<li><a href="qvulkandevicefunctions.html">QVulkanDeviceFunctions</a></li>
<li><a href="qvulkanextension.html">QVulkanExtension</a></li>
<li><a href="qvulkanfunctions.html">QVulkanFunctions</a></li>
<li><a href="qvulkaninfovector.html">QVulkanInfoVector</a></li>
<li><a href="qvulkaninstance.html">QVulkanInstance</a></li>
<li><a href="qvulkanwindow.html">QVulkanWindow</a></li>
<li><a href="qvulkanwindowrenderer.html">QVulkanWindowRenderer</a></li>
</ul>
<p>For more information, see the <a href="qtgui-hellovulkanwidget-example.html">Hello Vulkan Widget Example</a> and the <a href="qtgui-hellovulkanwindow-example.html">Hello Vulkan Window Example</a>.</p>
<a name="drag-and-drop"></a>
<h2 id="drag-and-drop">Drag and Drop</h2>
<p>More info in <a href="dnd.html">Drag and Drop</a></p>
<a name="licenses-and-attributions"></a>
<h2 id="licenses-and-attributions">Licenses and Attributions</h2>
<p>Qt GUI is available under commercial licenses from <a href="http://www.qt.io/about-us/">The Qt Company</a>. In addition, it is available under free software licenses. Since Qt 5.4, these free software licenses are <a href="http://www.gnu.org/licenses/lgpl-3.0.html">GNU Lesser General Public License, version 3</a>, or the <a href="http://www.gnu.org/licenses/gpl-2.0.html">GNU General Public License, version 2</a>. See <a href="../qtdoc/licensing.html">Qt Licensing</a> for further details.</p>
<p>Furthermore, Qt GUI in Qt 5.14.2 may contain third-party modules under following permissive licenses:</p>
<div class="table"><table class="annotated">
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-angle.html">ANGLE Library, version chromium/3280</a></p></td><td class="tblDescr"><p>BSD 3-clause &quot;New&quot; or &quot;Revised&quot; License</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-angle-arrayboundsclamper.html">ANGLE: Array Bounds Clamper for WebKit</a></p></td><td class="tblDescr"><p>BSD 2-clause &quot;Simplified&quot; License</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-angle-murmurhash.html">ANGLE: Murmurhash</a></p></td><td class="tblDescr"><p>Public Domain</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-angle-systeminfo.html">ANGLE: Systeminfo</a></p></td><td class="tblDescr"><p>BSD 2-clause &quot;Simplified&quot; License</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-angle-trace-event.html">ANGLE: trace_event</a></p></td><td class="tblDescr"><p>BSD 3-clause &quot;New&quot; or &quot;Revised&quot; License</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-aglfn.html">Adobe Glyph List For New Fonts, version 1.7</a></p></td><td class="tblDescr"><p>BSD 3-Clause &quot;New&quot; or &quot;Revised&quot; License</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-grayraster.html">Anti-aliasing rasterizer from FreeType 2</a></p></td><td class="tblDescr"><p>Freetype Project License or GNU General Public License v2.0 only</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-vera-font.html">Bitstream Vera Font, version 1.10</a></p></td><td class="tblDescr"><p>Bitstream Vera Font License</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-cocoa-platform-plugin.html">Cocoa Platform Plugin</a></p></td><td class="tblDescr"><p>BSD 3-clause &quot;New&quot; or &quot;Revised&quot; License</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-dejayvu.html">DejaVu Fonts, version 2.37</a></p></td><td class="tblDescr"><p>Bitstream Vera Font License</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-freetype-bdf.html">Freetype 2 - Bitmap Distribution Format (BDF) support</a></p></td><td class="tblDescr"><p>MIT License</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-freetype-pcf.html">Freetype 2 - Portable Compiled Format (PCF) support</a></p></td><td class="tblDescr"><p>MIT License</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-freetype-zlib.html">Freetype 2 - zlib</a></p></td><td class="tblDescr"><p>zlib License</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-freetype.html">Freetype 2, version 2.10.1</a></p></td><td class="tblDescr"><p>Freetype Project License or GNU General Public License v2.0 only</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-harfbuzz.html">HarfBuzz</a></p></td><td class="tblDescr"><p>MIT License</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-harfbuzz-ng.html">HarfBuzz-NG, version 1.7&#x2e;4</a></p></td><td class="tblDescr"><p>MIT License</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-iaccessible2.html">IAccessible2 IDL Specification, version 1.3&#x2e;0</a></p></td><td class="tblDescr"><p>BSD 3-clause &quot;New&quot; or &quot;Revised&quot; License</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-libjpeg.html">LibJPEG-turbo, version 2.0&#x2e;3</a></p></td><td class="tblDescr"><p>Independent JPEG Group License</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-libpng.html">LibPNG, version 1.6&#x2e;37</a></p></td><td class="tblDescr"><p>libpng License and libpng License 2</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-md4c.html">MD4C, version 0.4&#x2e;3</a></p></td><td class="tblDescr"><p>MIT License</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-android-native-style.html">Native Style for Android</a></p></td><td class="tblDescr"><p>Apache License 2.0</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-opengl-es2-headers.html">OpenGL ES 2 Headers, version Revision 27673</a></p></td><td class="tblDescr"><p>MIT License</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-opengl-headers.html">OpenGL Headers, version Revision 27684</a></p></td><td class="tblDescr"><p>MIT License</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-pixman.html">Pixman, version 0.17.12</a></p></td><td class="tblDescr"><p>MIT License</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-smooth-scaling-algorithm.html">Smooth Scaling Algorithm</a></p></td><td class="tblDescr"><p>BSD 2-clause &quot;Simplified&quot; License and Imlib2 License</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-vulkan-xml-spec.html">Vulkan API Registry, version 1.0&#x2e;39</a></p></td><td class="tblDescr"><p>MIT License</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-vulkanmemoryallocator.html">Vulkan Memory Allocator, version 2.2&#x2e;0</a></p></td><td class="tblDescr"><p>MIT License</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-webgradients.html">WebGradients</a></p></td><td class="tblDescr"><p>MIT License</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-wintab.html">Wintab API</a></p></td><td class="tblDescr"><p>Custom License</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-xserverhelper.html">X Server helper</a></p></td><td class="tblDescr"><p>X11 License and Historical Permission Notice and Disclaimer</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qtgui-attribution-xcb.html">XCB</a></p></td><td class="tblDescr"><p>MIT License</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qtgui-attribution-icc-srgb-color-profile.html">sRGB color profile icc file</a></p></td><td class="tblDescr"><p>International Color Consortium License</p></td></tr>
</table></div>
<a name="reference"></a>
<h2 id="reference">Reference</h2>
<ul>
<li><a href="qtgui-module.html">Qt GUI C++ Classes</a><ul>
<li><a href="../qtcore/events.html">Event Classes</a></li>
<li><a href="painting.html">Painting Classes</a></li>
<li><a href="painting-3d.html">Rendering in 3D</a></li>
</ul>
</li>
</ul>
</div>
<!-- @@@qtgui-index.html -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
